/*******************************************************************************
*  file    : main.cpp
*  created : 22.07.2013
*  author  : Slyshyk Oleksiy (alexSlyshyk@gmail.com)
*******************************************************************************/

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QQmlComponent>

#include "backupguicontroller.hpp"

int main(int argc, char *argv[])
{
    int appRes = 0;
    try
    {
        QCoreApplication::setApplicationName ("backuper");
        QCoreApplication::setOrganizationName("Slyshyk" );
        QGuiApplication a(argc, argv);

        qmlRegisterType<BackupGuiController>("App.Controller", 0,1, "Controller");

        QQmlApplicationEngine engine(QUrl("qrc:qml/src/qml/main.qml"));
        QObject*              topLevel = engine.rootObjects().value(0);
        QQuickWindow*         window   = qobject_cast<QQuickWindow *>(topLevel);
        if ( window )
            {
                window->setX(100);
                window->setY(100);
                window->show();
                appRes = a.exec();
            }
        else
            {
                qWarning("Error: Your root item has to be a Window.");
                appRes = -1;
            }
    }
    catch(...)
    {
        appRes = 0x666;
    }
    return appRes;
}

